import pygame
import sys
pygame.init()
size=width,height=(600, 600)
bg_color=(89,230,180)
pos=[300,0]
rect = [300, 450, 80,30]
speed = 1
screen=pygame.display.set_mode(size)
clock = pygame.time.Clock()
while 1:
    for event in pygame.event.get():
        if event.type==pygame.QUIT:
            sys.exit()
        elif event.type == pygame.KEYDOWN:
            if event.key == pygame.K_LEFT:
                if rect[0]>10:
                    rect[0] -= 20
            elif event.key == pygame.K_RIGHT:
                if rect[0]+80 < width:
                    rect[0] += 20

    screen.fill(bg_color)
    pygame.draw.circle(screen,(0,0,0),pos,10)
    pygame.draw.rect(screen, (0, 255,0), rect)
    pos[1]+=speed
    clock.tick(100)
    pygame.display.update()
